import Cesium, { ScreenSpaceEventHandler } from '../Ces/Cesium'

/**
 * 点击后停止跳转
 */
class FlyHandler {
  private _eventHandler: ScreenSpaceEventHandler
  callback: any
  constructor(WE) {
    this._eventHandler = new Cesium.ScreenSpaceEventHandler(WE.viewer.scene.canvas)
    this._eventHandler.setInputAction(() => {
      WE.viewer.camera.cancelFlight()
      WE.handlerManager.enableFlyHandler = false
      if (this.callback) this.callback()
    }, Cesium.ScreenSpaceEventType.LEFT_DOWN)
  }

  destroy() {
    //@ts-ignore
    this._eventHandler = this._eventHandler && this._eventHandler.destroy()
    return Cesium.destroyObject(this)
  }

  isDestroyed() {
    return false
  }
}


export default FlyHandler
